package com.syj.collect.model;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.syj.collect.Present.MonthPresent;
import com.syj.collect.Present.UserPresent;
import com.syj.collect.adapter.MyMonthAdapter;
import com.syj.collect.app.R;
import com.syj.collect.base.BaseMvpAvtivity;
import com.syj.collect.base.EmptyRecyclerView;
import com.syj.collect.entry.Mymonth;
import com.syj.collect.view.MonthActivityView;
import com.syj.collect.view.UserActivityView;

import java.util.List;

public class MyMonthActivity extends BaseMvpAvtivity<MonthActivityView, MonthPresent> implements MonthActivityView {

    @Override
    public MonthPresent initPresenter() {
        return new MonthPresent();
    }
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_month);
        initTitle("月报");
        initView();
        presenter.getDataList();
    }
    private SmartRefreshLayout smartRefreshLayout;
    private EmptyRecyclerView com_rerec;
    private MyMonthAdapter myMonthAdapter;
    private void initView() {
        smartRefreshLayout=findViewById(R.id.comm_refresh);
        com_rerec=findViewById(R.id.com_rerec);
        com_rerec.setEmptyView(findViewById(R.id.empty_view_));
        myMonthAdapter=new MyMonthAdapter(this);
        com_rerec.setLayoutManager(new LinearLayoutManager(this));
        com_rerec.setAdapter(myMonthAdapter);
        myMonthAdapter.setOnItemClickListener(new MyMonthAdapter.OnItemClickListener() {
            @Override
            public void onClick(String url) {
                Intent intent=new Intent(MyMonthActivity.this,PdfActivity.class);
                intent.putExtra("url",url);
                startActivity(intent);

            }
        });


    }


    @Override
    public void initsuccess(List<Mymonth.DataDTO.ListDTO> list) {
//        Log.e("tag结果 :", "!2122");
        if (list!=null){

            myMonthAdapter.addList(list);
        }

    }

    @Override
    public void initfail() {

    }
}
